<template>
  <div class="container" @click="handleGarrlaryClose">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <!-- slides -->
        <swiper-slide v-for="(img,index) in imgs" :key="index">
          <img class="galler-img" :src="img" />
        </swiper-slide>
        <div class="swiper-pagination pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: "Gallary",
  props: {
    imgs: {
      type: Array
    }
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination",
        paginationType: "fraction",
        // 重新刷新，计算宽度
        observeParents:true,
        observer:true
      }
    };
  },
  methods: {
    handleGarrlaryClose() {
      this.$bus.$emit('handleGarrlaryClose')
    }
  },
};
</script>

<style lang="less" scoped>
.container {
  position: fixed;
  display: flex;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  flex-direction: column;
  justify-content: center;
  background-color: #000;
  z-index: 99;
  color: #fff;
}
.wrapper {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
}
.galler-img {
  width: 100%;
}

.pagination {
  position: fixed;
  bottom: 0.2rem;
}
</style>
